<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link href="/weixin/css/mui.min.css" rel="stylesheet" />
		<style type="text/css">
			.lmj-hide{
				display:none;
			}
			#saveEditBtn{
				padding: 4px !important;
				font-size: 16px !important;
				width: 88% !important;
			    margin-top: 10px;
   				margin-left: 6%;
			}
		</style>
	</head>

	<body>
		
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-back mui-pull-left"></a>
		    <h1 id="headerTitle" class="mui-title">我的资料</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group" id="editform">
				<div class="mui-input-row">
					<label id="inputTitle"></label>
					<input type="text" class="mui-input-clear" placeholder="">
				</div>
			</form>
			
			<ul class="mui-table-view mui-table-view-radio lmj-hide" id="sexUl">
				<li class="mui-table-view-cell mui-selected">
					<a class="mui-navigate-right">
						男
					</a>
				</li>
				<li class="mui-table-view-cell">
					<a class="mui-navigate-right">
						女
					</a>
				</li>
			</ul>
			
			<button type="button" class="mui-btn mui-btn-primary mui-btn-block" id="saveEditBtn">保存修改</button>
		</div>
		
		<script src="/weixin/js/mui.min.js"></script>
		<script src="/weixin/js/jquery.min.js"></script>
		<script src="/weixin/js/comment.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.ready(function(){
		        //通过url获得buyMealId
		        var editMark = getUrlParam('editMark');
		        
		        var headerTitle="";
		        switch (editMark){
		        	case '1':
		        	headerTitle="签名";
		        	jQuery('#saveEditBtn').attr('data-id','signature');
		        	break;
		        	case '2':
		        	headerTitle="性别";
		        	jQuery('#saveEditBtn').attr('data-id','sex');
		        	break;
		        	case '3':
		        	headerTitle="城市";
		        	jQuery('#saveEditBtn').attr('data-id','city');
		        	break;
		        	case '4':
		        	headerTitle="职业";
		        	jQuery('#saveEditBtn').attr('data-id','profession');
		        	break;
		        	case '5':
		        	headerTitle="邮箱";
		        	jQuery('#saveEditBtn').attr('data-id','email');
		        	break;
		        	case '6':
		        	headerTitle="身份证";
		        	jQuery('#saveEditBtn').attr('data-id','idCard');
		        	break;
		        	case '7':
		        	headerTitle="手机号";
		        	jQuery('#saveEditBtn').attr('data-id','mobile');
		        	break;
		        }
		        jQuery('#headerTitle').text("修改"+headerTitle);
		        if(editMark!='2'){
		        	jQuery('#inputTitle').text(headerTitle);
		        }else{
		        	jQuery('#editform').addClass('lmj-hide');
		        	jQuery('#sexUl').removeClass('lmj-hide');
		        }
		        
		        jQuery('#saveEditBtn').bind('click',function(){
		        	var urlPar=jQuery(this).attr('data-id');
		        	var urlParValue="";
		        	if(jQuery('#editform').hasClass('lmj-hide')){
		        		//取性别的值
		        		if(jQuery('#sexUl').find('li:eq(0)').hasClass('mui-selected')){
		        			//选择男
		        			urlParValue='1';
		        		}else{
		        			//选择女
		        			urlParValue='2';
		        		}
		        	}else{
		        		//取文本框的值
		        		urlParValue=jQuery('#editform').find('input').val();
		        	}
		        	console.log(urlPar+""+urlParValue);
		        	var data = {},Par=urlPar;
					data[Par]=urlParValue;
		        	jQuery.ajax({
		        		type:'get',
		        		url:ajaxUrlPath+'/wx/member/update',
		        		data:data,
		        		success:function(data){
		        			if(data=='success'){
		        				mui.alert('修改成功', '美丽乡村', function() {
									window.location='myself.html';
								});
		        			}else{
		        				mui.alert('网络不稳定，请稍后再试...', '美丽乡村');
		        			}
		        		},
		        		error:function(){
		        			console.log('dd');
		        		}
		        	})
		        });
			});
		</script>
	</body>

</html>